<template>
  <div>
    <!-- 配置暂定 -->

    <el-dialog
      title="素材选择"
      :visible.sync="dialogVisible2"
      width="70%"
      :before-close="dialogBeforeClose"
      :close-on-click-modal="false"
    >
      <div class="filter-container">
        <div class="filter-container">
          <el-button type="primary" @click="dialogVisible1 = true">添加素材</el-button>
        </div>
        <el-table
          :data="materialData"
          row-key="id"
          style="width: 100%"
          border
          @selection-change="handleSelectionChange"
        >
          <el-table-column type="selection" width="55" align="center" />
          <el-table-column type="index" width="55" label="序号" align="center" />
          <el-table-column prop="strMaterialname" label="标题" align="center" />
          <el-table-column prop="typeName" label="类型" align="center" />
          <el-table-column prop="strOrgname" label="所属机构" align="center" />
          <el-table-column prop="strDownload" label="下载地址" align="center" />
          <el-table-column prop="time" label="播放时间(秒)" width="125" align="center">
            <template slot-scope="{row}">
              <el-input v-model="row.iPlaytime" />
            </template>
          </el-table-column>
          <el-table-column fixed="right" align="center" label="操作" width="240">
            <template slot-scope="scope">
              <el-button
                type="primary"
                size="mini"
                @click.native.prevent="deleteRow(scope.$index, materialData)"
              >移除</el-button>
              <el-button
                size="mini"
                type="primary"
                @click="replaceMaterial(scope.row,scope.$index)"
              >替换</el-button>
            </template>
          </el-table-column>
        </el-table>
      </div>
      <el-button type="primary" @click="publishPrograms('form')">添加</el-button>
      <div slot="footer">
        <el-button @click="dialogVisible = false">取 消</el-button>
        <el-button type="primary" @click="dialogVisible = false">确 定</el-button>
      </div>
    </el-dialog>

    <el-dialog title="新增素材" :visible.sync="dialogVisible1" :close-on-click-modal="false">
      <div class="container">
        <el-form :model="addForm" label-width="80px">
          <el-col :span="8">
            <el-form-item label="所属机构" label-width="80px">
              <el-cascader
                v-model="addForm.iOrgsysnum"
                :show-all-levels="false"
                :options="optionsNum"
                :props="{ expandTrigger: 'hover', checkStrictly: true, value:'strOrgnum',label:'strOrgname',children: 'yhlist' }"
              />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item prop="strMaterialdetail" label="素材标签">
              <el-select v-model="addForm.strMaterialdetail" placeholder="请选择素材标签">
                <el-option
                  v-for="item in optionTag"
                  :key="item.id"
                  :label="item.strValue"
                  :value="item.strCode"
                />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="2" class="searbtn">
            <el-form-item>
              <el-button type="primary" @click="addsearch()">搜索</el-button>
            </el-form-item>
          </el-col>
        </el-form>
        <el-table :data="addTableData" style="width: 100%" border @selection-change="changeFun">
          <el-table-column type="selection" width="55" align="center" />
          <el-table-column type="index" width="55" label="序号" align="center" />
          <el-table-column prop="strMaterialname" label="标题" align="center" />
          <el-table-column prop="typeName" label="类型" align="center" />
          <el-table-column prop="strMaterialdetail" label="标签" align="center" />
          <el-table-column prop="strDownload" label="下载地址" align="center" />
          <el-table-column prop="type" label="操作" align="center">
            <template slot-scope="{row,$index}">
              <el-button size="mini" type="primary" @click="handaddsearch(row,$index)">详情</el-button>
            </template>
          </el-table-column>
        </el-table>
      </div>
      <div slot="footer">
        <el-button @click="dialogVisible = false">取 消</el-button>
        <el-button type="primary" @click="addsearchture(),dialogVisible = false">确 定</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
export default {
  props: {
    visible: {
      type: Boolean,
      default: false
    }
  },
  data() {
    return {
      addForm: {
        iOrgsysnum: '',
        strMaterialdetail: ''
      },
      dialogVisible1: false,
      dialogVisible2: this.visible,
      optionsNum: [],
      optionTag: [],
      addTableData: [],
      materialData: []
    }
  },
  created() {
    console.log('css', this.visible)
  },
  methods: {
    handleSelectionChange() {

    },
    dialogBeforeClose() {

    },
    changeFun() {

    }
  }
}
</script>

<style lang="scss" scoped>
</style>
